package com.example.springboottestgit.service.instruction.stage1;

import com.example.springboottestgit.bean.InstructData;
import com.example.springboottestgit.common.RunNum;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;


@Service
public class MarginService {
    public List<InstructData> getInstructData() {
        List<InstructData> list = new ArrayList<>();
        for (int i = 0; i < RunNum.A; i++) {
            list.add(bzj());
        }
        return list;
    }

    //保证金
    public InstructData bzj() {
        Random random = new Random();
        int ysmin = 10000;
        int ysmax = 1000000;

        int ys = random.nextInt(ysmax - ysmin + 1) + ysmin;
        int ysje = ys * 100;
        int zgbzj = (int) (ysje * 0.02);

        //System.out.println("采购项目预算金额：" + ysje);
        //System.out.println("最高保证金额：" + zgbzj);
        int bzjmin = 10000;
        int bzjmax = 1000000;
        int bzj = random.nextInt(bzjmax - bzjmin + 1) + bzjmin;
        //System.out.println("投标保证金：" + bzj);

        String flag = bzj <= ysje * 0.02 ? "未超过" : "超过";
        //System.out.println(flag);
        String d = bzj == ysje * 0.02 ? "等于" : flag;


        String instruction = "根据《中华人民共和国政府采购法实施条例》规定，投标保证金不得超过采购项目预算金额的2%，那么请问投标保证金b元是否超过采购项目预算金额y元的2%？";
        String input = "";
        String output = "#，在这个例子中，采购项目预算金额是y元，采购项目预算金额的2% = y元 × 2% = y元 × 0.02 = z元，由于投标保证金金额b元d计算出的预算金额的2%（z元），所以投标保证金b元#采购项目预算金额y的2%。";

        instruction = instruction.replace("b", String.valueOf(bzj)).replace("y", String.valueOf(ysje));
        output = output.replaceAll("b", String.valueOf(bzj)).replace("y", String.valueOf(ysje)).replace("#", flag).replace("d", d).replace("z", String.valueOf(zgbzj));

        InstructData instructData = new InstructData();
        instructData.setInstruction(instruction);
        instructData.setInput("");
        instructData.setOutput(output);
        return instructData;
    }


}
